package com.java.simple.study.juc.p3;

import java.text.SimpleDateFormat;

/**
 * @author zhoujl
 * @date 2022/5/7 21:12
 * @desc 写一个线程安全的final类
 */
public final class Immutable {

    private static String s = "abc";


    public static void main(String[] args) {
        System.out.println(Immutable.s);
        m1();
        System.out.println(Immutable.s);
    }

    public static void m1() {
        s = "haha";
        System.out.println(s);
    }


    private final int value;

    public Immutable(int value) {
        this.value = value;
    }

    public int getValue() {
        return value;
    }

    public Immutable set(int value) {
        // 产生一个新对象
        return new Immutable(value);
    }
}
